package com.ctl.szmd.szmd.feature_wm.ui.viewmodel

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.ctl.szmd.szmd.feature_wm.data.bean.WmDataBean
import com.ctl.szmd.szmd.feature_wm.data.repository.WmRepository
import com.ctl.szmd.szmd.feature_wm.ui.base.BaseWmViewModel
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.onCompletion
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.launch

/**
 * created by : chentl
 * Date: 2020/08/17
 */
class MeViewModel(private val repository: WmRepository) : BaseWmViewModel() {
    var mUserInfo = MutableLiveData<WmDataBean>()

    fun getUserInfo() = viewModelScope.launch {
        repository.getFulianMyCenterMyInfo()
            .onStart {
            }
            .catch {
            }
            .onCompletion {
            }
            .collectLatest {
                mUserInfo.postValue(it)
            }
    }
}